package com.aaa.service.impl;

import com.aaa.dao.FuserMapper;
import com.aaa.entity.Fuser;
import com.aaa.entity.SecurityUser;
import com.aaa.service.FuserServiceDao;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FuserServiceImpl extends ServiceImpl<FuserMapper, Fuser> implements FuserServiceDao {
    @Resource
   FuserMapper fuserMapper;
//    @Override
//    public List<Fuser> findFuser(String name) {
//        return fuserMapper.findFuser(name);
//    }

    @Override
    public SecurityUser loadUserByUsername(String username) {
        List<Fuser> fuserList = fuserMapper.selectList(new QueryWrapper<Fuser>().eq("name", username));
        if (fuserList.size()==1){
            Fuser fuser = fuserList.get(0);
            System.out.println(fuser);
            return new SecurityUser(fuser.getName(),fuser.getPassword(),fuser.getState()==0,"bbb",fuser.getId());
        }
        return null;
    }
}
